package one.stand.config;

import one.stand.interceptor.LoginInterceptor;
import one.stand.interceptor.ParamInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Administrator
 */
@Configuration
public class WebAppConfig implements WebMvcConfigurer {
    @Autowired
    @Lazy
    LoginInterceptor loginInterceptor;

    @Autowired
    @Lazy
    ParamInterceptor paramInterceptor;

    private String[] swagger = { "/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**","/doc.html"};


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加一个拦截器，拦截以/test为前缀的 url路径
        registry.addInterceptor(paramInterceptor).addPathPatterns("/**").excludePathPatterns(swagger);
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns(swagger);
    }

}
